package com.lxd.api.filter.Impl;

import com.lxd.api.filter.CheckFilter;
import com.lxd.common.enums.ExceptionEnums;
import com.lxd.common.exception.ApiException;
import com.lxd.common.model.StandardSubmit;
import com.lxd.common.utils.PhoneFormatCheckUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service(value = "mobile")
@Slf4j
public class MobileCheckFilter implements CheckFilter {



    @Override
    public void check(StandardSubmit submit) {
        String mobile = submit.getMobile();
        log.info("【接口模块-校验手机号】手机号：mobile={}",mobile);
        if (mobile!=null && PhoneFormatCheckUtil.isChinaPhone(mobile)){
            log.info("【接口模块-校验手机号】   校验成功…………");
            return;
        }
        log.info("【接口模块-校验手机号】   校验失败！…………");
        throw new ApiException(ExceptionEnums.ERROR_MOBILE);
    }
}
